package com.yuan.java.pack16;

public class SocketPackUtils {

    public static byte[] hexStr2ByteArr(String hexString) {
        hexString = hexString.replaceAll(" ", "");
        int len = hexString.length();
        int index = 0;
        byte[] bytes = new byte[len / 2];
        while (index < len) {
            String sub = hexString.substring(index, index + 2);
            bytes[index / 2] = (byte) Integer.parseInt(sub, 16);
            index += 2;
        }
        return bytes;
    }

    public static String byteArr2HexStrBlank(byte[] paramArrayOfByte) {
        return arr2HexStr(paramArrayOfByte, true);
    }

    public static String byteArr2HexStr(byte[] paramArrayOfByte) {
        return arr2HexStr(paramArrayOfByte, false);
    }

    private static String arr2HexStr(byte[] paramArrayOfByte, boolean haveBlank) {
        int i = 0;
        int k = paramArrayOfByte.length;
        StringBuilder localStringBuffer = new StringBuilder(k * 2);
        while (i < k) {
            int j = paramArrayOfByte[i];
            while (j < 0) {
                j += 256;
            }
            if (j < 16) {
                localStringBuffer.append("0");
            }
            localStringBuffer.append(Integer.toString(j, 16).toUpperCase()).append(haveBlank ? " " : "");
            i += 1;
        }
        return localStringBuffer.toString();
    }




    public static void main(String[] args) throws Exception {
       String a = "00000000";
        System.out.println(a.split("").length);
    }

}
